// ======================== 拖拽 ========================

// 在元素正在拖动到放置目标时触发

/**
 * 初始化，开启拖拽监听
 */
export const initCanvasWidgetDrag = function () {
  // design widget-list
  let canvas = document.getElementById('design')
  canvas.ondragover = function (e) {
    e.preventDefault()
  }
  // 在一个拖动过程中，释放鼠标键时触发此事件
  canvas.ondrop = function (e) {

    let widgetCode = e.dataTransfer.getData('widget-code')
    console.log('widgetCode', widgetCode)
    let args = {
      'msg': 'ondrop handler',
      'x': e.x,
      'y': e.y,
      'code': widgetCode,
      'e': e,
      'clazz': 'widget',
      'source': '@/plugins/design/drag.js#initCanvasWidgetDrag()'
    }

    // args.x = e.offsetX
    // args.y = e.offsetY
    // $nuxt.$emit('console.dev', args)
    $nuxt.$emit('widget-drop-to-canvas', args)
  }
}

export const listener = function () {
  $nuxt.$on('my-custom-event', () => {
    console.log('监听事件总线。22。。')
  })
}

    // ======================== end 拖拽 ======================